how to check end of string in java